<?php

/***  DOCUMENTATION LAYER

Last Update: Mar 2007
	
DESCRIPTION
	test array_smart_dump()
	
NOTES
	
***/

// Timer
$_tx0 = microtime();

// HEADER
echo "<h1 style='margin:8px 0 0;'>Klenwell Sandbox</h1>";
echo "<h4 style='margin:0 0 16px;'>array_lottery()</h4>";	// put script name here

// *** PROCEDURAL
if ( 0 ) 
{
	echo "<h4 style='margin:0; color:blue;'>Testing in Progess</h4>";
}


$_DIR['php'] = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
require_once($_DIR['php'] . 'array/array_smart_dump.inc.php');


// Test Function
if ( 1 )
{
	$run = 3;
	echo "<h2 style='margin:0; color:green;'>Function Test</h2>";	
	echo "<h4 style='margin:4px 0 0'>Array Smart Dump</h4>";
	
	// some array names
	$NAME = array('DATA', 'SUPER_ARRAY', 'NORMA_ARRAY', 'ARRAY_JAY', 'TEST', 'SAMPLE', 'DEMO');
	
		
	while ( $run )
	{	
		// build random array
		$ARRAY = array();
		$z = 0;
  	for ( $i = 0; $i < mt_rand(10,20); $i++ ) 
  	{
  		$SUBARRAY = array();
  		for ( $j = 0; $j < mt_rand(1,3); $j++ ) 
  		{
  			$z++; 
  			$SUBARRAY[substr(md5($z),-3)] = md5(mt_rand(1,1000)); 
  		} 
  		$ARRAY[substr(md5($i),-3)] = $SUBARRAY; 
  	}
		
		// get smart array
		$array_name = $NAME[array_rand($NAME)];
		$SMART_ARRAY = array_smart_dump($ARRAY, $array_name);
		
		// output
		$array_dump = print_r($ARRAY,1);
		$smart_array_dump = print_r($SMART_ARRAY,1);
		
		echo "<h4 style='margin:8px 0 0; color:#f00;'>print_r($ARRAY)</h4><pre style='border:1px solid #fcc; background:#fff3f3;'>$array_dump</pre>";
		echo "<h4 style='margin:8px 0 0; color:#0f0;'>SMART ARRAY (ready to be written to file)</h4><pre style='border:1px solid #cfc; background:#f3fff3;'>$smart_array_dump</pre>";
		
		
		echo "<h6 style='margin:0; color:#ccc;'>test #{$run} complete</h6>";
		$run--;
	}		
}

// Footer
$_txn = microtime();
$stx = number_format(((substr($_txn,0,9)) + (substr($_txn,-10)) - (substr($_tx0,0,9)) - (substr($_tx0,-10))),4); 
$footer = <<<HTML
<h4 style="margin:0; position:absolute; top:6px; right:6px; font-family:monospace; color:#36f; padding:4px; border:1px solid #36f; font-weight:normal; background:#f3f6ff;">
script completed in $stx s
</h4>
HTML;
echo $footer;

?>
